#-*- coding:utf-8 -*-
from TakeHtmFile import HtmDomList,htm_full_file
from TakeCssFile import NewFileContent,css_full_file
import sys,os
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)

FinResult = list(set(NewFileContent).difference(set(HtmDomList))) # b中有而a中没有的



def PrintResult(result):#将结果写入到网页文件函数
    global htm_full_file,css_full_file
    htm_name = os.path.basename(htm_full_file)
    css_name = os.path.basename(css_full_file)
    fin_code_befor = '<!DOCTYPE html><html lang="en"><head><title>Heicss - 结果输出</title><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta charset="UTF-8"><link rel="stylesheet" href="css/bootstrap.min.css"><link href="css/reveal-it.css" rel="stylesheet" type="text/css"/><link href="css/main.css" rel="stylesheet" type="text/css"/></head><body><div class="container"><div class="row"><div class="col-xs-12"><h1 class="text-center"><h1>Heicss 结果输出页面</h2></h1></div></div></div><div class="container"><div class="row"><div class="col-xs-12"><div class="box1"><h2>输出结果仅供参考！修改源代码前请务必备份！<h4><a href="http://heicss.raisetion.com/">返回（提示，这会删除当前页面）</a></h4><h5 class="h5_left bg-primary text-danger">本次上传的HTML文件为：' + htm_name + '</h5><h5 class="h5_right bg-primary text-danger">css文件为：' + css_name + '</h5></h2></div></div></div></div><div class="container"><div class="row"><div class="col-xs-12"><div>'
    fin_code_after = '</div></div></div></div><script type="text/javascript" src="js/jquery-1.11.1.min.js"></script><script type="text/javascript" src="js/bootstrap.min.js"></script><script type="text/javascript" src="js/reveal-it.js"></script><script type="text/javascript" src="js/main.js"></script></body></html>\n'
    fopen = open('/var/www/html/result/fin.html','w')
    fopen.write(fin_code_befor + result + fin_code_after)
    fopen.close()

StrFinResult = ''

for x in FinResult:
    StrFinResult = StrFinResult + x + '<br>'

StrFinResult = StrFinResult.replace('<br>\n<br>','<br>')#删除结果网页中的空白行
PrintResult(StrFinResult)#结果写入网页文件

os.remove(htm_full_file)
os.remove(css_full_file)